/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package MyGame;

import edu.chalmers.AV_2DPlatformerFramework.Model.GameObject;
import edu.chalmers.AV_2DPlatformerFramework.Model.Hitbox;
import edu.chalmers.AV_2DPlatformerFramework.Model.Texture;
import edu.chalmers.AV_2DPlatformerFramework.Utility.Vector2D;

/**
 * @version 0.1
 * @author Andrea Buchholz
 */
public class Object_Pill extends GameObject {

    public int pills = 0;
    
    Object_Pill() throws Hitbox.HitboxMalformedException {
        super(null);
        Vector2D[] vertices = {new Vector2D(0, 0), new Vector2D(23, 0),
                new Vector2D(23, 23), new Vector2D(0, 23)};
        setHitbox(new Hitbox(vertices));
        String s = System.getProperty("file.separator");
        addTexture(new Texture("."+s+"src"+s+"main"+s+"java"+s+"Textures"
                           +s+"pill.png", this.getHitbox().getBounds2D()));
        setVelocity(new Vector2D(0,0));
    }

    public void setPills(){
        this.pills++;
    }
    
    public int getPills(){
        return this.pills;
    }
    
    @Override
    public void onCollision(GameObject otherObject) {
        
        if ((otherObject instanceof Object_Edmund)){
            this.setPosition(new Vector2D(-100000, -100000));
            setPills();
        }
    }

    @Override
    public GameObject copy() {
        try {
           Object_Pill copy = new Object_Pill();
           this.copyVariablesTo(copy);
           return copy;
        } catch (Hitbox.HitboxMalformedException ex) {
            return null;
        }
    }
}
